사이트 내 전체검색
PHP
1. 그냥 GD로 PNG 이미지 파일 만들기
로빈아빠
https://cmd.kr/php/556 URL이 복사되었습니다.

본문

<?
    header 
("Content-type: image/png");

    
$width "271";
    
$height "131";

    
$im=ImageCreate($width,$height);  // 이미지의 크기를 정합니다.

    
$white ImageColorAllocate ($im255255255);// 사용할 색상 설정 
    
$gray ImageColorAllocate($im,200,200,200);  // 사용할 색상 설정

    
ImageRectangle($im,0,0,270,130$gray);

    
ImageTTFText($im,10,0,5,128,$gray,"fonts/H2SA1M.TTF","Create By Wizard.");

    
ImagePNG($im);
    
ImageDestroy($im); // 이미지에 사용한 메모리 제거
?>


처음에 이미지를 Create 한다.
$white 색상을 alloc 해주면 Create된 이미지 바탕색이 흰색으로 칠해진다.
만약 $white 보다 $gray를 먼저 Alloc 해주면 바탕색이 회식이 된다.
그다음에 ImageRectangle 해서 걍 테두리 회색으로 칠하고
ImageTTFText 로 걍 글씨 썼음.
[1의 실행예]

이것을 다른 이미지 파일을 포게보장..

2. 1과 다른 이미지를 포갠다.
<?
    header 
("Content-type: image/png");

    include 
"gdkorea.php";

    
$width "271";
    
$height "131";

    
$im=ImageCreate($width,$height);  // 이미지의 크기를 정합니다.
    
$im2    imagecreatefromgif("intro.gif");

    
$white ImageColorAllocate ($im255255255);// 사용할 색상 설정 
    
$gray ImageColorAllocate($im,200,200,200);  // 사용할 색상 설정

    
ImageCopyMerge ($im$im20000271,131,100);

    
ImageRectangle($im,0,0,270,130$gray);

    
ImageTTFText($im,10,0,5,128,$gray,"fonts/H2SA1M.TTF","Create By Wizard.");

    
ImagePNG($im);
    
ImageDestroy($im); // 이미지에 사용한 메모리 제거
?>


1과 똑같은데 $im2 즉, gif 파일읽어오는 부분이 흰색 Alloc 해주기전에 있다는것과 ImageCopyMerge를 해줬다는것.. 맨뒤에 100 이란 숫자가 있는데 이것은 투명도라고 생각하면 될것 같다.
[2의 실행예]
[2의 intro.gif 그림파일]

정보공유라이선스 이 저작물은 정보공유 라이센스 2.0 : 영리금지·개작금지에 따라 이용하실수 있습니다.

댓글목록

등록된 댓글이 없습니다.

PHP
871 (8/18P)

Search

Copyright © Cmd 명령어 18.221.37.56